<!--
 * @Author: 刘程琳 2796055305@qq.com
 * @Date: 2025-09-11 08:37:06
 * @LastEditors: 刘程琳 2796055305@qq.com
 * @LastEditTime: 2025-09-17 16:02:51
 * @FilePath: \23信算前端\city\src\pages\components\Left1.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div>
        <Title :title="title"></Title>

        <!-- 提供图表容器 -->
        <div ref="bottom4" style="height:150px;"></div>
    </div>
</template>
<script>
import { Pie } from '@antv/g2plot';
import { get } from '@/utils/request';
import { Rose } from '@antv/g2plot';
import { mapState } from 'vuex';
import { rosePlot } from '@antv/g2plot';
import moment from 'moment';
export default {
    data() {
        return {
            title: '检测视频',
            // 存放设备状态
            params: {
                page: 1,
                pageSize: 100
            },
            // 存放温度数据
            monDate: [],
            // 创建一个图表实例
            rosePlot: null
        }
    },
    computed: {
        ...mapState(['ed'])
    },
    watch: {
        ed: {
            handler(n, o) {
                // 重新查询数据重新渲染图表
                this.params.engineer_id = n.engineer_id;
                this.params.device_id = n.device_id;
                this.getVideoDate();
                // 根据最新获取数据重新渲染图表
                this.Rose.changeData(this.videoDate);
            },
            // 深度监听
            deep: true
        }
    },
    methods: {
        loadPie() {

            const data = [
                { type: '第一季度', value: 18 },
                { type: '第二季度', value: 25 },
                { type: '第三季度', value: 18 },
                { type: '第四季度', value: 15 },
                
            ];
             

            const PATTERN_MAP = {
                第一季度: {
                    type: 'dot',
                    cfg: {
                        size: 20,
                        padding: 5,
                        fill: '#fff',
                        strokeOpacity: 1,
                        opacity: 0.8,
                    },
                },
                第二季度: {
                    type: 'line',
                    cfg: {
                        stroke: '#FFA884',
                        lineWidth: 5,
                        spacing: 10,
                        rotation: 90,
                        backgroundColor: '#F2EAEA',
                    },
                },
                第三季度: {
                    type: 'square',
                    cfg: {
                        size: 3,
                        fill: '#014c63',
                        padding: 6,
                    },
                },
                label: {
                    style: {
                        fill: 'white',
                        fontSize: 16
                    }
                },
               
                
                shapeStyle: {
                    showMarkers: true,
                    domStyles: {
                        "g2-tooltip": {
                            background: 'purple',
                            color: "white",
                            fontSize: 20
                        }
                    }
                }
            };

            const rosePlot = new Rose(this.$refs.bottom4, {
                label: {
                    style: {
                        fill: 'white',
                        fontSize: 16
                    }
                },
                 tooltip: {
                    showMarkers: true,
                    domStyles: {
                        "g2-tooltip": {
                            background: 'orange',
                            color: "white",
                            fontSize: 20
                        }
                    }
                    },
                data,
                xField: 'type',
                yField: 'value',
                seriesField: 'type',
                radius: 0.9,
                legend: false,
                pattern: ({ type }) => {
                    return PATTERN_MAP[type] || { type: 'line' };
                },
            
            });

            rosePlot.update({
                theme: {
                    styleSheet: {
                        brandColor: '#215B77',
                        paletteQualitative10: [
                            '#215B77',
                            '#1B9CD0',
                            '#61C9FF',
                            '#ABDFFF',
                            '#EFF3DE',
                            '#FFDE94',
                            '#FFC741',
                            '#D09C10',
                            '#795B16',
                        ],
                        paletteQualitative20: [
                            '#215B77',
                            '#227BA2',
                            '#1B9CD0',
                            '#22BAED',
                            '#61C9FF',
                            '#8AD4FF',
                            '#ABDFFF',
                            '#C9E9FF',
                            '#EFF3DE',
                            '#FFE9B8',
                            '#FFDE94',
                            '#FFD470',
                            '#FFC741',
                            '#EDB40A',
                            '#D09C10',
                            '#A37B16',
                            '#795B16',
                        ],
                    },
                },
            });
            rosePlot.render();
        }
        },


            // 方法必须加小括号
            mounted() {

                this.loadPie();
            }
        }

</script>
<style lang="less" scoped></style>